
public class RoboterList extends List {

	// adds element to list and returns true if instance of roboter, if not returns false
	@Override
	public boolean add(Object element) {
		if(!(element instanceof Roboter)) {
			return false;
		}
		return super.add(element);
	}
	
	// removes object with roboter id from list, false if id invalid or not removed, true if removed
	public boolean remove(Object element) {
		if(!(element instanceof Integer)) {
			return false;
		}
		Roboter roboterToRemove = getElement(element);
		return super.remove(roboterToRemove);
	}
	
	// returns Roboter with given id, null if id invalid or not found
	@Override
	public Roboter getElement(Object objId) {
		if(!(objId instanceof Integer)) {
			return null;
		}
		Integer roboterId = (Integer)objId;
		Iterator it = iterator();
		while(it.hasNext()) {
			Roboter r = (Roboter)it.next();
			if(r.ID.equals(roboterId)) {
				return r;
			}
		}
		return null;
	}
}
